package com.tianma.upload.uploadjartest.socket.demo01;

import java.io.*;
import java.net.Socket;

/**
 * @author lgc
 * @createDate 2020/8/17 - 11:32
 */
public class ServerSocket {
    public static void main(String[] args) throws IOException {
        java.net.ServerSocket serverSocket = new java.net.ServerSocket(8888);
        Socket accept = serverSocket.accept();
        InputStream inputStream = accept.getInputStream();
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        byte[] bytes = new byte[1024];
        int read = 0;
        String s = "";
        while ((read = inputStream.read(bytes))!=-1){
            baos.write(bytes,0,read);
        }
        System.out.println("baos = " + baos);
        baos.close();
        inputStream.close();
        accept.close();
    }
}
